﻿using Fabrication.Exceptions;
using Fabrication.Tests.TestClasses;
using NUnit.Framework;

namespace Fabrication.Tests
{
    [TestFixture]
    public class property_selection
    {
        [Test]
        public void should_handle_property_selector_for_valid_property()
        {
            var options = new FabricationScope().Setup<SinglePropertyClass<int>>();
            Assert.DoesNotThrow(() => options.For(x => x.Value));
        }

        [Test]
        public void should_throw_exception_if_property_selector_is_null()
        {
            var options = new FabricationScope().Setup<SinglePropertyClass<string>>();
            Assert.Throws<PropertySelectorException>(() => options.For<SinglePropertyClass<string>, string>(null));
        }

        [Test]
        public void should_throw_exception_if_property_selector_is_not_a_property()
        {
            var options = new FabricationScope().Setup<ClassWithMethod>();
            Assert.Throws<PropertySelectorException>(() => options.For(x => x.MethodWithReturnValue()));
        }
    }
}